package commonDataStructures;

public class GenBoard<E>{

	SuperArray<SuperArray<E>> _board;

	public GenBoard(int width,int height){
		_board = new SuperArray<SuperArray<E>>(height);
		for(int i=0;i<height;i++){
			_board.set(i, new SuperArray<E>(width));
			_board.get(i).set(width-1,null);
		}
	}

	public E get(int x,int y){
		return _board.get(_board.size()-1-y).get(x);
	}

	public void set(int x,int y,E e){
		_board.get(_board.size()-1-y).set(x, e);
	}

	public int getWidth(){
		return _board.get(0).size();
	}

	public int getHeight(){
		return _board.size();
	}

	public void printBoard(){

		for(int y=getHeight()-1;y>-1;y--){
			for(int x=0;x<getWidth();x++){
				System.out.print(get(x,y)+", ");
			}
			System.out.println();
		}
		System.out.println();
	}

	public static void main(String[] args){
		GenBoard<Integer> a = new GenBoard<Integer>(4,4);
		a.set(0, 0, 1);
		a.printBoard();
		System.out.println(a.get(0,0));
	}
}
